import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      meta:{isCheck: false}
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('../views/AboutView.vue'),
      meta:{isCheck: false, isCache:true}
    },
    {
      path: '/goods',
      name: 'goods',
      component: () => import('../views/GoodsList.vue'),
    },
    {
      path: '/goodsDetail/:id',
      name: 'gDetail',
      components: {
        default:() => import('../views/GoodsDetail.vue')
      },
      props: {
        default:true
      }
    },
    {
      path: '/news',
      name: 'news',
      component: () => import('../views/NewsView.vue'),
      meta:{isCheck: true},
      children:[{
        path: 'detail/:id',
        name: 'detail',
        components: {
          default:() => import('../views/NewsDetailView.vue')
        },
        props: {
          default:true
        }
      }]
    },
    {
      path: '/join',
      name: 'join',
      component: () => import('../views/AboutView.vue'),
      meta:{isCheck: false}
    },
    {
      path: '/case',
      name: 'case',
      component: () => import('../views/AboutView.vue'),
      meta:{isCheck: true}
    },
    {
      path: '/list',
      name: 'list',
      component: () => import('../views/ListView.vue')
    }
  ]
})

router.beforeEach((to)=>{
  // console.log(to.meta)
  // console.log(to.meta.isCheck)
  // console.log(to.meta.isCache)
  // if(to.meta.isCheck && isLogin){}
})

export default router
